package com.xiaobaibai.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaobaibai.dao.UserDao;
import com.xiaobaibai.entity.User;
import com.xiaobaibai.service.IUserService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaobaibai
 * @since 2020-10-16
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserDao, User> implements IUserService {

    @Override
    public boolean haveOne(String openId) {
        return this.baseMapper.haveOne(openId)==1;
    }

    @Override
    @Cacheable(value = "user",key = "#root.methodName+'-'+#userId")
    public User getDetailByUserId(Integer userId) {
        QueryWrapper<User> q1=new QueryWrapper<>();
        q1.eq("user_id",userId);
        q1.select("user_id","user_name","user_image","user_phone");
        return this.getOne(q1);
    }

}
